#ifndef STARTMENU_H
#define STARTMENU_H
#include "VisableObject.h"
#include "MenuButton.h"
#include <iostream>
using namespace std;


class StartMenuManager : public VisableObject
{

public:
	StartMenuManager(sf::Vector2f startPos = sf::Vector2f(640.0f, 360.0f), float scale = 1.0f, sf::Vector2f startVel = sf::Vector2f(0, 0), const char* fileName = "images/Scene.png") : VisableObject(startPos, startVel, fileName, scale)
	{
		startButton = new MenuButton(sf::Vector2f(0.0f, 0.0f), "images/ButtonStart.png", 1.0f);
		startButton->pos = sf::Vector2f(640.0f, 240.0f);
		sf::Vector2f startButtonSize = (sf::Vector2f)startButton->mySprite.getTexture()->getSize() * startButton->scale;
		float topleftX = startButton->pos.x - 0.5f * startButtonSize.x;
		float topleftY = startButton->pos.y - 0.5f * startButtonSize.y;
		float bottomRightX = startButton->pos.x + 0.5f * startButtonSize.x;
		float bottonRightY = startButton->pos.y + 0.5f * startButtonSize.y;
		startButton->startPos = sf::Vector2f(topleftX, topleftY);
		startButton->endPos = sf::Vector2f(bottomRightX, bottonRightY);

		exitButton = new MenuButton(sf::Vector2f(0.0f, 0.0f), "images/ButtonExit.png", 1.0f);
		exitButton->pos = sf::Vector2f(640.0f, 480.0f);
		sf::Vector2f exitButtonSize = (sf::Vector2f)exitButton->mySprite.getTexture()->getSize() * exitButton->scale;
		topleftX = exitButton->pos.x - 0.5f * exitButtonSize.x;
		topleftY = exitButton->pos.y - 0.5f * exitButtonSize.y;
		bottomRightX = exitButton->pos.x + 0.5f * exitButtonSize.x;
		bottonRightY = exitButton->pos.y + 0.5f * exitButtonSize.y;
		exitButton->startPos = sf::Vector2f(topleftX, topleftY);
		exitButton->endPos = sf::Vector2f(bottomRightX, bottonRightY);
	};
	void Update(float deltaT) {};
	~StartMenuManager(){};

	MenuButton* startButton;
	MenuButton* exitButton;

	bool StartButtonIsPressed(sf::Vector2f pressPos)
	{
		if (pressPos.x > startButton->startPos.x && pressPos.x < startButton->endPos.x &&
			pressPos.y > startButton->startPos.y && pressPos.y < startButton->endPos.y)
			return true;
		else
			return false;
	};

	bool ExitButtonIsPressed(sf::Vector2f pressPos)
	{
		if (pressPos.x > exitButton->startPos.x && pressPos.x < exitButton->endPos.x &&
			pressPos.y > exitButton->startPos.y && pressPos.y < exitButton->endPos.y)
			return true;
		else
			return false;
	};


	void DrawMenu(sf::RenderWindow* window)
	{
		window->clear();
		Render(window);
		startButton->Render(window);
		exitButton->Render(window);
		window->display();
	}
};

#endif // STARTMENU_H